#ifndef CLOCK_LAPLIST_HPP
#define CLOCK_LAPLIST_HPP

#include <cpp3ds/Graphics/Drawable.hpp>
#include <cpp3ds/Graphics/Text.hpp>
#include <cpp3ds/Window/Event.hpp>
#include <cpp3ds/System/Clock.hpp>
#include "TweenObjects.hpp"
#include "Chronometer.hpp"
#include "LapItem.hpp"
#include "GUI/Scrollable.hpp"
#include <TweenEngine/Tween.h>
#include <TweenEngine/TweenManager.h>
#include <memory>
#ifndef EMULATION
#include <3ds.h>
#endif

namespace Clock {

class LapList : public cpp3ds::Drawable, public Scrollable, public util3ds::TweenTransformable<cpp3ds::Transformable> {
public:
	void update(float delta);
	void processEvent(const cpp3ds::Event& event);

	LapList();
	~LapList();

	void addLap(cpp3ds::Time actualTime);
	void clearList();
	size_t count() const;

	virtual void setScroll(float position);
	virtual float getScroll();
	virtual const cpp3ds::Vector2f &getScrollSize();

protected:
	virtual void draw(cpp3ds::RenderTarget& target, cpp3ds::RenderStates states) const;

	void repositionItems(bool noAnim = false);
	void setEmptyListTextState(bool state);

private:
	float m_scrollPos;
	cpp3ds::Vector2f m_size;

	std::vector<std::shared_ptr<LapItem>> m_lapItems;
	util3ds::TweenText m_textEmptyList;

	TweenEngine::TweenManager m_tweenManager;

};

} // namespace Clock

#endif // CLOCK_LAPLIST_HPP
